class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        unordered_set<char> m;
        int l = 0, r = 0;
        int len = 0, ret = 0;
        while (l < s.size())
        {

            if (m.find(s[r]) == m.end())
            {
                m.insert(s[r]);
                cout << s[r];
                len = m.size();
                if (len > ret) ret = len;
                if (r < s.size() - 1) r++;
            }
            else {
                l++;
                m.clear();
                cout << endl;
                r = l;
            }
        }
        return ret;
    }
};